package com.canlihao.ui.utils;

import android.content.Context;
import android.content.SharedPreferences;

/*******
 *
 *Created by 李魏
 *
 *创建时间 2019/6/24
 *
 *类描述：
 *
 ********/
public class SharedPreferenceUtil {

    public static void savePreference(Context context, String key, String value) {

        SharedPreferences preference = context.getSharedPreferences("Login", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = preference.edit();
        editor.putString(key, value);
        editor.commit();//apply
    }
    public static void savePreferenceTwo(Context context, String key, String value) {

        SharedPreferences preference = context.getSharedPreferences("Else", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = preference.edit();
        editor.putString(key, value);
        editor.commit();
    }


    public static String getPreference( String key, Context context) {
        if (context != null) {
            SharedPreferences preference = context.getSharedPreferences("Login", Context.MODE_PRIVATE);
            if(!Tools.isEmpty(preference.getString(key, ""))) {
                return preference.getString(key, "");
            }
            return "";
        }
        return "";
    }

    public static String getPreferenceTwo( String key, Context context) {
        if (context != null) {
            SharedPreferences preference = context.getSharedPreferences("Else", Context.MODE_PRIVATE);
            if(!Tools.isEmpty(preference.getString(key, ""))) {
                return preference.getString(key, "");
            }
            return "";
        }
        return "";
    }



}
